//自定义权限指令
import store from '@/store/index'
export default {
    // 当被绑定的元素插入到 DOM 中时……
    inserted(el, binding, node) {
      const {
        value
      } = binding
         const buttonList = store.getters && store.getters.buttonList
      if (value) {
        const permissionRoles = value
        // console.log(permissionRoles)
        const hasPermission = buttonList.some(role => {
            // console.log(role)
            if(role=='*:*:*'){
                return permissionRoles
            }else{
                return permissionRoles.includes(role)
            }
        })
        if (!hasPermission) {
          el.parentNode && el.parentNode.removeChild(el)
        }
      } else {
        throw new Error(`使用方式： v-permission="['admin','editor']"`)
      }
    }
  }
 